<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace Portal\Controller;
use Common\Controller\HomebaseController;
/**
 * 文章列表
*/
class SblistController extends HomebaseController {

	//文章内页
	public function index() {	
		
		$smanage_model = D("Smanage"); //分页使用由此开始，必须先实例化model，可以不用实例Page类。
		$count = $smanage_model->where(array("sbzt"=>"正常"))->count();		
		$Page  = $this->Page($count,15);  // 实例化分页类 传入总记录数和每页显示的记录数(15)
		$show  = $Page->show("Admin");   // 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$sblists  = $smanage_model->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->where(array("sbzt"=>"正常"))->select();//当用户是超级管理员时，显示所有设备信息
		$sblists_count= $smanage_model->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->where(array("sbzt"=>"正常"))->count();//总记录数		
		$sbtype = M('Sbtype');
		$gtype = $sbtype->select();	
		$sbjg = M('Sbjg');
		$gjg = $sbjg->select();			
		$this -> assign('gjg',$gjg);
		$this -> assign('sblists_count',$sblists_count); //输出总记录数		
		$this -> assign('gtype',$gtype);	
		$this -> assign('sblists',$sblists);  // 赋值数据集
		$this -> assign('Page',$show);   // 赋值分页输出   	
    	$this -> display(':sblist'); //直接输出到Portal根目录下的sblist.html;
	}
	
	function ssearch(){
		$typename = I("post.type");
		$jg = I("post.jg");
		$keyword = I("post.keyword");
		//dump($keyword);
		//dump($typename);
		$smanage_model = D("Smanage");
		if($typename){
			$ssearchlists = $smanage_model->where(array("sblb"=>$typename))->select();		
			//dump($ssearchlists);
			$ssearchcount = $smanage_model->where(array("sblb"=>$typename))->count();
			//dump($ssearchcount);
		}
		if($jg){
			$ssearchlists = $smanage_model->where(array("sydw"=>$jg))->select();
			$ssearchcount = $smanage_model->where(array("sydw"=>$jg))->count();	
		}
		if($keyword){
			//dump($keyword);						
			$ssearchlists = $smanage_model->where(array("sbsn"=>$keyword))->select();			
		}		
		$this -> assign('ssearchlists',$ssearchlists);
		$this -> assign('ssearchcount',$ssearchcount);		
		$this -> display(':ssearch');		
	}
	
	function showinfo(){
			$id = intval(I('get.id'));
			$smanage_model = D('Smanage');
			$showinfo = $smanage_model->where(array("id"=>$id))->find();
			$this -> assign('showinfo',$showinfo);			
			$this->display(':showinfo');
			//dump($showinfo['id']);
			
    }	
	
}
